<?
REQUIRE("../../protect/connect_jeu.php");
REQUIRE ("../fonction.php");


$query="UPDATE tmp_upgrade SET upgrade_avancement=upgrade_avancement+(upgrade_tavancement*upgrade_tribu) ";
$resultat=mysql_query($query);

$query="SELECT T.upgrade_id,T.upgrade_batiment,T.upgrade_ville,T.upgrade_tribu,T.upgrade_user,T.upgrade_batiment_id,U.upgrade_batiment_niv,U.upgrade_batiment_name FROM tmp_upgrade AS T, uupgrade AS U WHERE T.upgrade_amelioration=U.upgrade_id AND  T.upgrade_avancement>=T.upgrade_total";
// 0 = ID , 1 = batiment_id, 2=ville, 3=tribu 4=structure 5=user 6=unit
$resultat=mysql_query($query);

   echo $query;
REQUIRE("../effet_batiment.php");


WHILE ($tmp=mysql_fetch_row($resultat)){
$VAR_TMP=0;



//Donner les effet a la ville si il y en a.
//*****************************************
IF (!empty($bonus)){

   //Pour chaque effet.
   $bon_tmp=EXPLODE("/",$bonus);
   $nbr_bonus=count($bon_tmp);

   FOR ($i=0;$i<$nbr_bonus;$i++){  //FOR #01
   $eff_tmp=EXPLODE("-",$bon_tmp[$i]);
   EFFET_BATIMENT($eff_tmp[0], $eff_tmp[1],$eff_tmp[2],$tmp[2]);


}//fin du for $i
}



$query="UPDATE sdbatiment SET batiment_niv=$tmp[6],batiment_name='$tmp[7]' WHERE batiment_id=$tmp[5]";
echo $query;
$resultat2=mysql_query($query);

      $pex=250;
//Experience du au a la construction.
//***********************************
$query="UPDATE sduser_perso SET perso_exp=perso_exp+$pex WHERE perso_id=$tmp[5]";
$resultat2=mysql_query($query);



//Effacer la construction
//***********************
$query="DELETE FROM tmp_upgrade WHERE upgrade_id=$tmp[0]";
$resultat2=mysql_query($query);


}//fin du WHILE ($tmp=mysql_fetch_row($resultat)){



mysql_close();



?>
